The Gamma Distribution The Gamma Distribution If a random variable X X X has the density
f ( x ) = x α − 1 e − x β Γ ( α ) β α f(x) = \displaystyle\frac{x^{\alpha-1} e^{\displaystyle\frac{-x} {\beta}}} {\Gamma(\alpha) \beta^{\alpha}} f ( x ) = Γ ( α ) β α x α − 1 e β − x
where x > 0 x>0 x > 0 for some constants α \alpha α , β > 0 \beta>0 β > 0 , then X X X is said to have a gamma distribution.
Details The function Γ \Gamma Γ is basically chosen so that f f f integrates to one, i.e.
Γ ( α ) = ∫ 0 ∞ t α − 1 e − t d t \Gamma(\alpha) = \displaystyle\int_0^\infty t^{\alpha-1} e^{-t}dt Γ ( α ) = ∫ 0 ∞ t α − 1 e − t d t
It is not too hard to see that Γ ( n ) = ( n − 1 ) ! \Gamma(n)=(n-1)! Γ ( n ) = ( n − 1 )! if n ∈ N n \in \mathbb{N} n ∈ N .
Also, Γ ( α + 1 ) = α Γ ( α ) \Gamma(\alpha + 1) = \alpha \Gamma(\alpha) Γ ( α + 1 ) = α Γ ( α ) for all α > 0 \alpha > 0 α > 0 .
The Mean, Variance and Mgf of the Gamma Distribution Suppose X ∼ G ( α , β ) X \sim G (\alpha, \beta) X ∼ G ( α , β ) i.e. X X X has density
f ( x ) = x α − 1 e − x / β Γ ( α ) β α , x > 0 f(x) = \displaystyle\frac{x^{\alpha -1} e^{-x/\beta}} {\Gamma (\alpha) \beta^{\alpha}}, x > 0 f ( x ) = Γ ( α ) β α x α − 1 e − x / β , x > 0
Then,
E [ X ] = α β E[X] = \alpha\beta E [ X ] = α β
M ( t ) = ( 1 − β t ) − α M(t) = (1-\beta t)^{-\alpha} M ( t ) = ( 1 − βt ) − α
V a r [ X ] = α β 2 Var[X] = \alpha \beta^2 Va r [ X ] = α β 2
Details The expected value of X X X can be computed as follows:
E [ X ] = ∫ − ∞ ∞ x f ( x ) d x = ∫ 0 ∞ x x α − 1 e − x / β Γ ( α ) β α d x = Γ ( α + 1 ) β α + 1 Γ ( α ) β α ∫ 0 ∞ x ( α + 1 ) − 1 e − x / β Γ ( α + 1 ) β α + 1 d x = α Γ ( α ) β α + 1 Γ ( α ) β α \begin{aligned} E[X] &= \displaystyle\int_{-\infty}^{\infty} xf(x)dx \\ &= \displaystyle\int_{0}^{\infty} x \displaystyle\frac{x^{\alpha -1} e^{-x/\beta}} {\Gamma (\alpha) \beta^{\alpha}} dx \\ &= \displaystyle\frac{\Gamma(\alpha+1)\beta^{\alpha+1}}{\Gamma(\alpha)\beta^{\alpha}} \displaystyle\int_{0}^{\infty} \displaystyle\frac{x^{(\alpha+1) -1} e^{-x/\beta}} {\Gamma (\alpha+1) \beta^{\alpha+1}} dx \\ &= \displaystyle\frac{\alpha\Gamma(\alpha)\beta^{\alpha+1}}{\Gamma(\alpha)\beta^{\alpha}} \end{aligned} E [ X ] = ∫ − ∞ ∞ x f ( x ) d x = ∫ 0 ∞ x Γ ( α ) β α x α − 1 e − x / β d x = Γ ( α ) β α Γ ( α + 1 ) β α + 1 ∫ 0 ∞ Γ ( α + 1 ) β α + 1 x ( α + 1 ) − 1 e − x / β d x = Γ ( α ) β α α Γ ( α ) β α + 1 so E [ X ] = α β E[X] = \alpha\beta E [ X ] = α β
Next, the moment-generating function is given by
E [ e t X ] = ∫ 0 ∞ e t x x α − 1 e − x / β Γ ( α ) β α d x = 1 Γ ( α ) β α ∫ 0 ∞ x α − 1 e t x − x / β d x = Γ ( α ) ϕ α Γ ( α ) β α ∫ 0 ∞ x ( α − 1 ) e − x / ϕ Γ ( α ) ϕ α d x \begin{aligned} E[e^{tX}] &= \displaystyle\int_{0}^{\infty} e^{tx} \displaystyle\frac{x^{\alpha-1}e^{-x/\beta}} {\Gamma(\alpha)\beta^{\alpha}} dx \\ &= \displaystyle\frac{1}{\Gamma(\alpha)\beta^{\alpha}} \displaystyle\int_{0}^{\infty} x^{\alpha-1} e^{tx - x/\beta} dx \\ &= \displaystyle\frac{\Gamma(\alpha) \phi^{\alpha} } {\Gamma(\alpha) \beta^{\alpha}} \displaystyle\int_{0}^{\infty} \displaystyle\frac{x^{(\alpha-1)} e^{-x/\phi}} {\Gamma (\alpha) \phi^{\alpha}}dx \end{aligned} E [ e tX ] = ∫ 0 ∞ e t x Γ ( α ) β α x α − 1 e − x / β d x = Γ ( α ) β α 1 ∫ 0 ∞ x α − 1 e t x − x / β d x = Γ ( α ) β α Γ ( α ) ϕ α ∫ 0 ∞ Γ ( α ) ϕ α x ( α − 1 ) e − x / ϕ d x if we choose ϕ \phi ϕ so that − x ϕ = t x − x / β \displaystyle\frac{-x}{\phi} = tx - x/\beta ϕ − x = t x − x / β i.e. − 1 ϕ = t − 1 β \displaystyle\frac{-1}{\phi} = t - \displaystyle\frac{1}{\beta} ϕ − 1 = t − β 1 i.e. ϕ = − 1 t − 1 / β = β 1 − β t \phi = - \displaystyle\frac{1}{t-1/\beta} = \displaystyle\frac{\beta}{1 - \beta t} ϕ = − t − 1/ β 1 = 1 − βt β then we have
M ( t ) = ( ϕ β ) α = ( β / ( 1 − β t ) β ) α = 1 ( 1 − β t ) α \begin{aligned} M(t) &= \left(\displaystyle\frac{\phi}{\beta}\right)^{\alpha} \\ &= \left(\displaystyle\frac{\beta / (1-\beta t)}{\beta}\right)^{\alpha} \\ &= \displaystyle\frac{1}{(1-\beta t)^{\alpha}} \end{aligned} M ( t ) = ( β ϕ ) α = ( β β / ( 1 − βt ) ) α = ( 1 − βt ) α 1 or M ( t ) = ( 1 − β t ) − α M(t) = (1-\beta t)^{-\alpha} M ( t ) = ( 1 − βt ) − α .
It follows that
M ′ ( t ) = ( − α ) ( 1 − β t ) − α − 1 ( − β ) = α β ( 1 − β t ) − α − 1 M'(t) = (-\alpha) (1-\beta t)^{-\alpha-1} (-\beta) = \alpha\beta(1-\beta t)^{-\alpha-1} M ′ ( t ) = ( − α ) ( 1 − βt ) − α − 1 ( − β ) = α β ( 1 − βt ) − α − 1
so M ′ ( 0 ) = α β M'(0) = \alpha\beta M ′ ( 0 ) = α β .
Further,
M ′ ′ ( t ) = α β ( − α − 1 ) ( 1 − β t ) − α − 2 ( − β ) = α β 2 ( α + 1 ) ( 1 − β t ) − α − 2 \begin{aligned} M''(t) &= \alpha\beta (-\alpha-1)(1-\beta t)^{-\alpha-2} (-\beta) \\ &= \alpha\beta^2 (\alpha+1)(1-\beta t)^{-\alpha-2} \end{aligned} M ′′ ( t ) = α β ( − α − 1 ) ( 1 − βt ) − α − 2 ( − β ) = α β 2 ( α + 1 ) ( 1 − βt ) − α − 2 E [ X 2 ] = M ′ ′ ( 0 ) = α β 2 ( α + 1 ) = α 2 β 2 + α β 2 \begin{aligned} E[X^2] &= M''(0) \\ &= \alpha\beta^2 (\alpha+1) \\ &= \alpha^2 \beta^2 + \alpha\beta^2 \end{aligned} E [ X 2 ] = M ′′ ( 0 ) = α β 2 ( α + 1 ) = α 2 β 2 + α β 2 Hence,
V a r [ X ] = E [ X ] 2 − E [ X ] 2 = α 2 β 2 + α β 2 − ( α β ) 2 = α β 2 \begin{aligned} Var[X] &= E[X]^2 - E[X]^2 \\ &= \alpha^2 \beta^2 + \alpha \beta^2 - (\alpha\beta)^2 \\ &= \alpha \beta^2 \end{aligned} Va r [ X ] = E [ X ] 2 − E [ X ] 2 = α 2 β 2 + α β 2 − ( α β ) 2 = α β 2 Special Cases of the Gamma Distribution: The Exponential and Chi-squared Distributions Consider the gamma density,
f ( x ) = x α − 1 e − x β Γ ( α ) β α , x > 0 f(x) = \displaystyle\frac {x^{\alpha - 1} e^{\displaystyle\frac{-x}{\beta}}} {\Gamma(\alpha) \beta^{\alpha}}, x > 0 f ( x ) = Γ ( α ) β α x α − 1 e β − x , x > 0
For parameters α , β > 0 \alpha, \beta > 0 α , β > 0
If α = 1 \alpha = 1 α = 1 then
f ( x ) = 1 β e − x β , x > 0 f(x) = \displaystyle\frac {1} {\beta} e^{\displaystyle\frac{-x}{\beta}}, x > 0 f ( x ) = β 1 e β − x , x > 0
and this is the density of exponential distribution
Consider next the case α = v 2 \alpha = \displaystyle\frac{v}{2} α = 2 v and β = 2 \beta = 2 β = 2 where v v v
is an integer, so the density becomes,
f ( x ) = x v 2 − 1 e − x 2 Γ ( v 2 ) Z v 2 , x > 0 f(x) = \displaystyle\frac {x^ {\displaystyle\frac{v}{2}- 1} e^{\displaystyle\frac{-x}{2}}} {\Gamma (\displaystyle\frac{v}{2}) Z^{\displaystyle\frac{v}{2}}}, x > 0 f ( x ) = Γ ( 2 v ) Z 2 v x 2 v − 1 e 2 − x , x > 0
This is the density of a chi-squared random variable with v v v degrees of freedom.
Details Consider, α = v 2 \alpha = \displaystyle\frac{v}{2} α = 2 v and β = 2 \beta = 2 β = 2 where v v v is an integer, so the density becomes,
f ( x ) = x v 2 − 1 e − x 2 Γ ( v 2 ) Z v 2 , x > 0 f(x) = \displaystyle\frac {x^ {\displaystyle\frac{v}{2}- 1} e^{\displaystyle\frac{-x}{2}}} {\Gamma (\displaystyle\frac{v}{2}) Z^{\displaystyle\frac{v}{2}}}, x > 0 f ( x ) = Γ ( 2 v ) Z 2 v x 2 v − 1 e 2 − x , x > 0
This is the density of a chi-squared random variable with v v v degrees of freedom
This is easy to see by starting with Z ∼ N ( 0 , 1 ) Z \sim N(0,1) Z ∼ N ( 0 , 1 ) and defining W = Z 2 W = Z^2 W = Z 2 so that the c.d.f.
is:
H ( w ) = P [ W ≤ w ] = P [ Z 2 ≤ w ] H _{(w)} = P [W \leq w] = P [ Z^2 \leq w] H ( w ) = P [ W ≤ w ] = P [ Z 2 ≤ w ]
= P [ − w ≤ Z ≤ w ] = P [ - \sqrt{w}\leq Z \leq \sqrt{w}] = P [ − w ≤ Z ≤ w ]
= 1 − P [ ∣ Z ∣ > w ] = 1 - P [|Z| > \sqrt{w}] = 1 − P [ ∣ Z ∣ > w ]
= 1 − 2 p [ Z < − w ] = 1-2p [Z< - \sqrt{w}] = 1 − 2 p [ Z < − w ]
= 1 − 2 ∫ − α w e − t 2 2 2 w d t = 1 − 2 ϕ ( w ) = 1 - 2 \displaystyle\int_{-\alpha}^{\sqrt{w}} \displaystyle\frac{e \displaystyle\frac{-t^2}{2}} {\sqrt{2w}} dt = 1 - 2\phi (\sqrt{w}) = 1 − 2 ∫ − α w 2 w e 2 − t 2 d t = 1 − 2 ϕ ( w )
The p.d.f.
of w w w is therefore
h ( w ) = H ′ ( w ) h(w) = H ^\prime(w) h ( w ) = H ′ ( w )
= 0 − 2 ϕ ′ ( w ) 1 2 w 1 2 − 1 = 0 - 2\phi ^\prime (\sqrt{w}) \displaystyle\frac{1} {2} w ^ {\displaystyle\frac{1} {2} -1} = 0 − 2 ϕ ′ ( w ) 2 1 w 2 1 − 1
but
ϕ ( x ) = ∫ − α x e − t 2 2 2 Π d t ϕ ′ ( x ) = d d x ∫ α x e − t 2 2 2 Π d t = e − x 2 2 2 Π \phi (x) = \displaystyle\int_{-\alpha}^{x} \displaystyle\frac{e \displaystyle\frac{-t^2}{2}} {2\Pi} dt \phi ^\prime (x) = \displaystyle\frac {d}{dx}\displaystyle\int_{\alpha}^{x}\displaystyle\frac{e \displaystyle\frac{-t^2}{2}} {2\Pi} dt = \displaystyle\frac{e \displaystyle\frac{-x^2}{2}} {2\Pi} ϕ ( x ) = ∫ − α x 2Π e 2 − t 2 d t ϕ ′ ( x ) = d x d ∫ α x 2Π e 2 − t 2 d t = 2Π e 2 − x 2
So
h [ w ] = − 2 e − w 2 2 Π . 1 2 . w 1 2 − 1 h[w] = -2 \displaystyle\frac{e \displaystyle\frac{-w}{2}} {2\Pi} . \displaystyle\frac {1} {2} . w^{\displaystyle\frac {1}{2} -1} h [ w ] = − 2 2Π e 2 − w . 2 1 . w 2 1 − 1
h [ w ] = w − 1 2 − 1 e − w 2 2 Π , w > 0 h[w] = \displaystyle\frac{w^ {\displaystyle\frac{-1}{2}-1} e \displaystyle\frac{-w}{2}} {2\Pi}, w > 0 h [ w ] = 2Π w 2 − 1 − 1 e 2 − w , w > 0
We see that we must have h = f h=f h = f with v = 1 v = 1 v = 1 .
We have also shown Γ ( 1 2 ) 2 1 2 = 2 π \Gamma (\displaystyle\frac {1}{2}) 2^{\displaystyle\frac{1}{2}} = \sqrt{2\pi} Γ ( 2 1 ) 2 2 1 = 2 π , i.e. Γ ( 1 2 ) = π \Gamma (\displaystyle\frac {1}{2}) = \sqrt{\pi} Γ ( 2 1 ) = π .
Hence we have shown the χ 2 \chi^2 χ 2 distribution on 1 df to be G ( α = v 2 , β = 2 ) G (\alpha = \displaystyle\frac {v}{2}, \beta = 2) G ( α = 2 v , β = 2 ) when v = 1 v = 1 v = 1 .
The Sum of Gamma Variables In the general case if X 1 … X n ∼ G ( α , β ) X_1 \ldots X_n \sim G (\alpha, \beta) X 1 … X n ∼ G ( α , β ) are independent identically distributed then X 1 + X 2 + … X n ∼ G ( n α , β ) X_1 + X_2 + \ldots X_n \sim G (n\alpha, \beta) X 1 + X 2 + … X n ∼ G ( n α , β ) .
In particular, if X 1 , X 2 , … , X v ∼ χ 2 X_1, X_2, \ldots, X_v \sim \chi^2 X 1 , X 2 , … , X v ∼ χ 2 independent identically distributed then Σ i = 1 v X i ∼ χ v 2 \Sigma_{i=1}^v X_i \sim \chi^2_{v} Σ i = 1 v X i ∼ χ v 2 .
Details If X X X and Y Y Y are independent identically distributed G ( α , β ) G (\alpha, \beta) G ( α , β ) , then
M X ( t ) = M Y ( t ) = 1 ( 1 − β t ) α M_X (t) = M_Y (t) = \displaystyle\frac {1} {(1- \beta t)^\alpha} M X ( t ) = M Y ( t ) = ( 1 − βt ) α 1
and
M X + Y ( t ) = M X ( t ) M Y ( t ) = 1 ( 1 − β t ) 2 α M_{X+Y} (t) = M_X (t) M_Y (t) = \displaystyle\frac {1} {(1- \beta t)^{2 \alpha}} M X + Y ( t ) = M X ( t ) M Y ( t ) = ( 1 − βt ) 2 α 1
So
X + Y ∼ G ( 2 α , β ) X + Y \sim G (2\alpha, \beta) X + Y ∼ G ( 2 α , β )
In the general case, if X 1 … X n ∼ G ( α , β ) X_1 \ldots X_n \sim G (\alpha, \beta) X 1 … X n ∼ G ( α , β ) are independent identically distributed then X 1 + X 2 + … X n ∼ G ( n α , β ) X_1 + X_2 + \ldots X_n \sim G (n\alpha, \beta) X 1 + X 2 + … X n ∼ G ( n α , β ) .
In particular, if X 1 , X 2 , … , X v ∼ χ 2 X_1, X_2, \ldots, X_v \sim \chi^2 X 1 , X 2 , … , X v ∼ χ 2 independent identically distributed, then ∑ i = 1 v X i ∼ χ v 2 \displaystyle\sum_{i=1}^v X_i \sim \chi^2_{v} i = 1 ∑ v X i ∼ χ v 2 .